﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Molia.AppCenter.Component
{
    public class PackageMarket
    {
        internal  List<Package> sources;
        string m_cache;
        public PackageMarket()
        {

        }
        public void SetCache(string file)
        {
            m_cache = file;
        }

        /// <summary>
        /// 从网络中获取全部的包
        /// </summary>
        public void GetPackageList()
        {
            var str = System.IO.File.ReadAllText(m_cache);
            sources = JsonConvert.DeserializeObject<List<Package>>(str);
            Service.MessageService.SendMessage(typeof(Package), sources, "PackageALL");
            System.Diagnostics.Debug.WriteLine("当前反序列化得到 {0} 个软件包.",sources.Count);
        }
        public void InstallPackage(Package target)
        {

        }
        public void UnInstallPackage(Package target)
        {

        }
    }
}
